﻿using AnQinFrameWorkAPI.Entity.Develop.DTO.DevelopProjectList;
using AnQinFrameWorkAPI.Entity.Develop.View.DevelopProjectList;
using AnQinFrameWorkAPI.Service.Develop;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Develop;

/// <summary>
///     开发管理项目列表
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Develop")]
public class DevelopProjectListController : ControllerBase
{
    //业务服务接口
    private readonly DevelopProjectListService _developProjectListService;

    //构造注入
    public DevelopProjectListController(DevelopProjectListService developProjectListService)
    {
        _developProjectListService = developProjectListService;
    }

    /// <summary>
    ///     获取开发管理项目列表
    /// </summary>
    /// <param name="developProjectListSearchDTO"></param>
    [ProducesResponseType(typeof(DevelopProjectListView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetDevelopProjectList(
        [FromQuery] DevelopProjectListSearchDTO developProjectListSearchDTO)
    {
        var response = await _developProjectListService.GetProjectList(developProjectListSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增开发管理项目
    /// </summary>
    /// <param name="developProjectListAddDTO"></param>
    [HttpPost]
    public async Task<IActionResult> AddDevelopProject([FromBody] DevelopProjectListAddDTO developProjectListAddDTO)
    {
        var response = await _developProjectListService.AddDevelopProject(developProjectListAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     更新开发管理项目
    /// </summary>
    /// <param name="developProjectListUpdateDTO"></param>
    [HttpPut]
    public async Task<IActionResult> PutDevelopProject(
        [FromBody] DevelopProjectListUpdateDTO developProjectListUpdateDTO)
    {
        var response = await _developProjectListService.PutDevelopProject(developProjectListUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除开发管理项目
    /// </summary>
    /// <param name="deleteDTO"></param>
    [HttpDelete]
    public async Task<IActionResult> DeleteDevelopProject([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _developProjectListService.DeleteDevelopProject(deleteDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     批量删除开发管理项目
    /// </summary>
    /// <param name="idArrayDTO"></param>
    [HttpPost("DeleteMulti")]
    public async Task<IActionResult> DeleteArrayDevelopProject([FromBody] IdArrayDTO idArrayDTO)
    {
        var response = await _developProjectListService.DeleteArrayDevelopProject(idArrayDTO);
        return StatusCode(response.Status, response);
    }
}